<?php
class Hydrum_Model
{

    public static function create($pathname)
    {
        $pathname = new Hydrum_Model_Pathname($pathname);
        $className = $pathname->getModelClassName();
        
        return new $className();
    }

    public static function getManager($pathname)
    {
        $pathname = new Hydrum_Model_Pathname($pathname);

        $config = Hydrum::getModelConfig($pathname);

        $manager = null;

        $managers = Hydrum::getResource('model-managers');

        if ($config && is_object($config) && $config->manager) {
            $manager = $managers->get($config->manager);
        } else {
            $manager = $managers->getDefault();
        }

        return $manager;
    }
    
    public static function getRepository($pathname)
    {
        $repository = null;
        
        $pathname = new Hydrum_Model_Pathname($pathname);
        $className = $pathname->getModelClassName();
        
        $manager = self::getManager($pathname);
        
        $repository = $manager->getRepository($className);
        
        return $repository;
    }
}
